package be.kuleuven.cs.mop.gui.components;


import java.awt.Font;

import javax.swing.JComboBox;



public class ComboSelector<T> extends JComboBox {
	private static final long serialVersionUID = 1L;
	
	private final T[] options;
	
	
	public ComboSelector(final T[] options) {
		super(options);
		setFocusable(false);
		setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 14));
		
		if ((options == null)/* || (options.length == 0)*/)
			throw new IllegalArgumentException("No options specified");
		this.options = options;
	}
	
	
	
	public T getSelection() {
		final int index = getSelectedIndex();
		return ((index == -1) ? null : options[index]);
	}
	
}